package com.biyao.service.model.base.imp;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import java.util.HashMap;
import java.util.Map;

import com.biyao.schedulingdao.base.TGrinderMapper;
import com.biyao.schedulingentity.base.TGrinderEntity;
import com.biyao.service.model.base.TGrinderMessage;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.ArrayList;
/**
 * 
 *
 * @author code generator
 * @date 2019-09-16 09:44:19
 */
@Service
public class TGrinderService extends ServiceImpl<TGrinderMapper, TGrinderEntity> implements TGrinderMessage {

    public Page list(int pageNum, int pageSize){

        EntityWrapper<TGrinderEntity> tGrinderentityWrapper=new EntityWrapper<>();
        Page page=selectPage(new Page(pageNum,pageSize),tGrinderentityWrapper);
        page.setRecords(formatRecords(page.getRecords()));
        return page;
    }

    List formatRecords(List<TGrinderEntity> list){
        List resList=new ArrayList();
        for(TGrinderEntity tGrinderEntity:list){
            Map map=formatEntity(tGrinderEntity);
            resList.add(map);
        }
        return resList;
    }

    Map formatEntity(TGrinderEntity tGrinderEntity){
        Map map=new HashMap(16);
        //磨床
        if(tGrinderEntity.getId()!=null){
           map.put("id",tGrinderEntity.getId());
        }
        //
        if(tGrinderEntity.getType()!=null){
           map.put("type",tGrinderEntity.getType());
        }
        if(tGrinderEntity.getCode()!=null){
            map.put("code",tGrinderEntity.getCode());
        }
        //生产厂家
        if(tGrinderEntity.getManufacturer()!=null){
           map.put("manufacturer",tGrinderEntity.getManufacturer());
        }
        //生产日期
        if(tGrinderEntity.getManufactureDate()!=null){
           map.put("manufactureDate",tGrinderEntity.getManufactureDate());
        }
        //投产日期
        if(tGrinderEntity.getCommissioningDate()!=null){
           map.put("commissioningDate",tGrinderEntity.getCommissioningDate());
        }
        //位置X
        if(tGrinderEntity.getLocationX()!=null){
           map.put("locationX",tGrinderEntity.getLocationX());
        }
        //位置Y
        if(tGrinderEntity.getLocationY()!=null){
           map.put("locationY",tGrinderEntity.getLocationY());
        }
        //位置Z
        if(tGrinderEntity.getLocationZ()!=null){
           map.put("locationZ",tGrinderEntity.getLocationZ());
        }

        if(tGrinderEntity.getGrindingAmount()!=null){
            map.put("grindingAmount",tGrinderEntity.getGrindingAmount());
        }

        //备注
        if(tGrinderEntity.getRemark()!=null){
           map.put("remark",tGrinderEntity.getRemark());
        }
        //创建时间
        if(tGrinderEntity.getCreateTime()!=null){
           map.put("createTime",tGrinderEntity.getCreateTime());
        }
        //更新时间
        if(tGrinderEntity.getUpdateTime()!=null){
           map.put("updateTime",tGrinderEntity.getUpdateTime());
        }
        //创建人
        if(tGrinderEntity.getCreateBy()!=null){
           map.put("createBy",tGrinderEntity.getCreateBy());
        }
        //更新人
        if(tGrinderEntity.getUpdateBy()!=null){
           map.put("updateBy",tGrinderEntity.getUpdateBy());
        }
        if(tGrinderEntity.getState()!=null){
            map.put("state",tGrinderEntity.getState());
        }
        if(tGrinderEntity.getMaintenanceDate()!=null){
            map.put("maintenanceDate",tGrinderEntity.getMaintenanceDate());
        }
        if(tGrinderEntity.getMaintenanceNote()!=null){
            map.put("maintenanceNote",tGrinderEntity.getMaintenanceNote());
        }
        if(tGrinderEntity.getMaintenanceUser()!=null){
            map.put("maintenanceUser",tGrinderEntity.getMaintenanceUser());
        }
        if(tGrinderEntity.getZhuzhouState()!=null){
            map.put("zhuzhouState",tGrinderEntity.getZhuzhouState());
        }
        if(tGrinderEntity.getToujiaState()!=null){
            map.put("toujiaState",tGrinderEntity.getToujiaDate());
        }
        if(tGrinderEntity.getWeijiaState()!=null){
            map.put("weijiaState",tGrinderEntity.getWeijiaDate());
        }
        if(tGrinderEntity.getTuowaState()!=null){
            map.put("tuowaState",tGrinderEntity.getTuowaState());
        }
        if(tGrinderEntity.getCeliangbiState()!=null){
            map.put("celiangbiState",tGrinderEntity.getCeliangbiState());
        }
        if(tGrinderEntity.getLengqueyeState()!=null){
            map.put("lengqueyeState",tGrinderEntity.getLengqueyeState());
        }
        if(tGrinderEntity.getOtherState()!=null){
            map.put("otherState",tGrinderEntity.getOtherState());
        }
        if(tGrinderEntity.getZhuzhouDate()!=null){
            map.put("zhuzhouDate",tGrinderEntity.getZhuzhouDate());
        }
        if(tGrinderEntity.getToujiaDate()!=null){
            map.put("toujiaDate",tGrinderEntity.getToujiaDate());
        }
        if(tGrinderEntity.getWeijiaDate()!=null){
            map.put("weijiaDate",tGrinderEntity.getWeijiaDate());
        }
        if(tGrinderEntity.getTuowaDate()!=null){
            map.put("tuowaDate",tGrinderEntity.getTuowaDate());
        }
        if(tGrinderEntity.getCeliangbiDate()!=null){
            map.put("celiangbiDate",tGrinderEntity.getCeliangbiDate());
        }
        if(tGrinderEntity.getLengqueyeDate()!=null){
            map.put("lengqueyeDate",tGrinderEntity.getLengqueyeDate());
        }
        if(tGrinderEntity.getOtherDate()!=null){
            map.put("otherDate",tGrinderEntity.getOtherDate());
        }
        return map;
    }

    @Override
    public TGrinderEntity selectEntryById(Integer id) {
        if(id!=null){
            return selectById(id);
        }
        return null;
    }
}

